package com.volunteer_sys.Dao;

import com.volunteer_sys.pojo.Activity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ActivityDao {
    @Select("select * from activities")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "start_time", column = "start_time"),
            @Result(property = "end_time", column = "end_time"),
            @Result(property = "location", column = "location"),
            @Result(property = "volunteer_num", column = "volunteer_num"),
            @Result(property = "contact_way", column = "contact_way"),
            @Result(property = "summary", column = "summary"),
            @Result(property = "status_id", column = "status_id"),
            @Result(property = "hours", column = "hours")
    })
    public List<Activity> getAllAtt();

    @Select("select * from activities where id = #{id}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "num", column = "num"),
    })
    public Activity getAttById(Integer id);

    @Insert("insert into activities(id,name,num)values(#{id},#{name},#{num})")
    int addAtt(Activity att);

    @Delete("DELETE form activities where id = #{id}")
    int removeAtt(Integer att_id);

}
